<template>
  <div class="container">
    <div>用户名:<el-input v-model="name" /></div>
    <div>密码:<el-input v-model="password" /></div>

    <div>
      还没有账号？<a
        href="#"
        class="xxx"
        @click.prevent="toRegist"
      >赶紧点我注册一个吧!</a>
    </div>
    <el-button @click="login({ name, password })">
      登录
    </el-button>
  </div>
</template>

<script>
import { mapActions } from 'vuex';

export default {
  name: 'Login',
  data() {
    return {
      name: '',
      password: '',
    };
  },
  methods: {
    ...mapActions(['login']),
    toRegist() {
      this.$router.push('/regist');
    },
  },
};
</script>

<style scoped>
.container {
  width: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.xxx {
  text-decoration: none;
}
</style>
